# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from threading import Thread

from time import sleep


def async_call(f):
    def wrapper(*args, **kwargs):
        thr = Thread(target=f, args=args, kwargs=kwargs)
        thr.start()
    return wrapper


@async_call
def A(callback):
    sleep(10)
    print('A sleep 10')
    print('A call')

    callback('AAA')
    return 'AAA'


def B(callback):
    sleep(3)
    print('B sleep 1')
    print('B call')

    callback('BBB')
    return 'BBB'


print('1')
ret1 = A(lambda res: print('a ok', res))
print('2', ret1)
ret2 = B(lambda res: print('b ok', res))
print('3', ret2)
